package edu.java.ishop.services;

import org.springframework.beans.factory.annotation.Value;

import edu.java.ishop.dao.impl.ProductDatabasaDao;
import edu.java.ishop.dao.impl.ProductFileDao;
import edu.java.ishop.dao.impl.ProductSocketDao;
import edu.java.ishop.utils.ApplicationConfiguration;

public class ProductServiceFactory {

	private ProductServiceFactory(){
		
	}
	@Value("${datasourceType}")
	private static String datasourceType;
	public static ProductService getInstetnce(){
		ProductService instance = null;
		switch(datasourceType//ApplicationConfiguration.getItem("datasourceType")){
				){
		case "socket" :
			instance = new ProductService();
			instance.setDao(new ProductSocketDao());
			return instance;
		case "database" :
			instance = new ProductService();
			instance.setDao(new ProductDatabasaDao());
			return instance;
		default: 
			instance = new ProductService();
			instance.setDao(new ProductFileDao());
			return instance;
		}
	}
}
